<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex myCollection_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between myCollection_fd0_0'>
				<view class='flex flex-wrap align-center myCollection_fd0_0_c0' @tap.stop="handleJumpDiy"
					data-type="back" data-url="1">
					<text class='fu-iconfont2  myCollection_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='myCollection_fd0_0_c1_c0'>我的收藏</text>
				</view>
				<view class='flex align-center justify-end myCollection_fd0_0_c2'>
					<!-- <text class='myCollection_fd0_0_c2_c0' v-if="edit_id=='1'" @tap.stop="switchEditFunc(2)">编辑</text>
					<text class='myCollection_fd0_0_c2_c0_1' v-if="edit_id=='2'" @tap.stop="switchEditFunc(1)">完成</text> -->
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#F35D2A"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		<block v-else>
			<!---搜索列表flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout myCollection_flex_1">
				<view class='flex flex-direction flex-wrap align-stretch'>
					<template v-for='(item,key0) in dataList'>
						<view class='flex align-start myCollection_fd1_0_c0' @tap.stop="handleJumpDiy"
							data-type="navigateTo"
							:data-url="`/pages/grzx/merchanDisedetails/merchanDisedetails?id=${item.goods_id}`" :key='key0'>
							<view class="select_icon" v-if="edit_id == 2" @tap.stop="checkItem(key0)">
								<image :src='STATIC_URL+"3.png"' mode="aspectFill" v-if="item.isSelect"></image>
								<image :src='STATIC_URL+"135.png"' mode="aspectFill" v-if="!item.isSelect"></image>
							</view>
							<view class="select_content flex flex-wrap align-center">
								<image class='myCollection_fd1_0_c0_c0' mode="aspectFill" :src='item.thumb'></image>
								<view
									class='flex flex-direction flex-wrap align-stretch flex-sub myCollection_fd1_0_c0_c1'>
									<text class='myCollection_fd1_0_c0_c1_c0'>{{item.goods_name}}</text>
									<view class='flex flex-wrap align-center myCollection_fd1_0_c0_c1_c1'>
										<text>{{item.collect_nums}}</text>
										<text class='myCollection_fd1_0_c0_c1_c1_c1'>收藏</text>
									</view>
									<view class='flex flex-wrap align-center'>
										<text class='myCollection_fd1_0_c0_c1_c2_c0'>￥</text>
										<view class=' myCollection_fd1_0_c0_c1_c2_c1'>
											<text
												class=' myCollection_price1_fd1_0_c0_c1_c2_c1'>{{ item.shop_price | frontPrice }}</text>
											<text
												class=' myCollection_price2_fd1_0_c0_c1_c2_c1'>{{ item.shop_price | laterPrice }}</text>
										</view>
										<text class='myCollection_fd1_0_c0_c1_c2_c4'>销量</text>
										<text class='myCollection_fd1_0_c0_c1_c2_c5'>{{item.sales_sum}}</text>
									</view>
								</view>
							</view>
						</view>
					</template>
					<u-loadmore v-if="last_page > 1" style="padding: 24rpx 0;width: 100%;" :status="status"
						:icon-type="iconType" :load-text="loadText" />
				</view>
			</view>
			<view class="noData" v-if="dataList.length == 0 && !isShow">
				<image :src='STATIC_URL+"no.png"'></image>
			</view>
			<!---搜索列表flex布局结束-->

			<view class="flex flex-direction align-stretch benben-position-layout flex myCollection_flex_3"
				v-if="edit_id=='2' && dataList.length > 0">
				<view class='flex align-center justify-between flex-sub myCollection_fd3_0'>
					<view class='flex flex-wrap align-center' @tap.stop="checkAll">
						<view class='flex flex position-relative align-center' v-if="collectAlls">
							<image class='myCollection_checkfd3_0_c0_c0_c0_c0' mode="aspectFit"
								:src='STATIC_URL+"3.png"'>
							</image>
						</view>
						<view class='flex flex position-relative justify-end align-center' v-else>
							<image class='myCollection_noCheckfd3_0_c0_c0_c1_c0' mode="aspectFit"
								:src='STATIC_URL+"135.png"'></image>
						</view>
						<text class='myCollection_fd3_0_c0_c1'>全选</text>
					</view>
					<view class="flex align-center">
						<button class='myCollection_fd3_0_c1' @tap.stop="deteleFunc()">删除</button>
						<button class='myCollection_fd3_0_c1_x' @tap.stop="switchEditFunc(1)">完成</button>
					</view>
				</view>
			</view>
			<view class="flex flex-direction align-stretch benben-position-layout flex myCollection_flex_3"
				v-if="edit_id=='1' && dataList.length > 0">
				<view class='flex align-center justify-between flex-sub myCollection_fd3_0'>
					<view class='flex flex-wrap align-center'>
						
					</view>
					<button class='myCollection_fd3_0_c1' @tap.stop="switchEditFunc(2)">管理</button>
				</view>
			</view>
		</block>


		<view :style="{height: '100rpx'}"></view>


	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"collect_id": "",
				"collectAlls": false,
				"edit_id": "1",
				"collect_type": [{
					"name": "",
					"value": "1",
					"image": ""
				}],
				"ids": "",
				"dataList": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {
			dataList: {
				handler(value) {
					let arr = [];
					value.forEach((v, k) => {
						if (v.isSelect) {
							arr.push(v.id);
						}
					})
					this.ids = arr.join(',');
				},
				deep: true,
				immediate: true,
			}
		},
		onLoad(options) {},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.DataListFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.DataListFunc()
		},
		onReachBottom(e) {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {

				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.DataListFunc();
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			//切换编辑收藏
			switchEditFunc(id) {
				this.edit_id = id;
			},
			checkItem(k) {
				this.dataList[k].isSelect = !this.dataList[k].isSelect;
				let index = this.dataList.find((val) => val.isSelect == false);
				this.$forceUpdate();
				if (index == undefined) {
					this.collectAlls = true;
				} else {
					this.collectAlls = false;
				}
			},
			checkAll() {
				this.collectAlls = !this.collectAlls;
				if (this.collectAlls) {
					this.dataList.forEach((v, k) => {
						v.isSelect = true;
					})
				} else {
					this.dataList.forEach((v, k) => {
						v.isSelect = false;
					})
				}
			},
			//获取收藏列表
			DataListFunc() {
				this.$api.post(global.apiUrls.post6551ce9708713, {
					page: this.page
				}).then(res => {
					console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						if (res.data.data.data.length > 0) {
							res.data.data.data.forEach((v, k) => {
								v.isSelect = false;
							})
						}
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.dataList = res.data.data.data;
						} else {
							this.dataList = this.dataList.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			//删除收藏
			deteleFunc() {
				if (!this.ids) {
					this.$message.info('请选择商品');
					return;
				}
				this.$api.post(global.apiUrls.post6551cf7f74874, {
					collect_ids: this.ids
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						this.edit_id = 1;
						this.collectAlls = false;
						this.page = 1;
						this.is_pull = true;
						this.isShow = true;
						this.DataListFunc()
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.select_icon {
		position: relative;
		width: 42rpx;
		margin: 0 12rpx 0 0;

		image {
			width: 32rpx;
			height: 32rpx;
			position: absolute;
			top: 80rpx;
			left: 5rpx;
		}
	}

	.select_content {
		flex: 1;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}

	.myCollection_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.myCollection_fd0_0_c2_c0_1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.myCollection_fd0_0_c2_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.myCollection_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 200rpx;
	}

	.myCollection_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.myCollection_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.myCollection_fd0_0_c0 {
		width: 200rpx;
	}

	.myCollection_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.myCollection_flex_1 {
		padding: 12rpx 0rpx 12rpx 0rpx;
	}

	.myCollection_fd1_0_c0_c1_c2_c6 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd1_0_c0_c1_c2_c5 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd1_0_c0_c1_c2_c4 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.myCollection_price2_fd1_0_c0_c1_c2_c3 {
		font-size: 24rpx;
	}

	.myCollection_fd1_0_c0_c1_c2_c3 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		text-decoration: line-through;
	}

	.myCollection_fd1_0_c0_c1_c2_c2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx 16rpx;
		text-decoration: line-through;
	}

	.myCollection_price2_fd1_0_c0_c1_c2_c1 {
		font-size: 32rpx;
	}

	.myCollection_price1_fd1_0_c0_c1_c2_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: #EA3D1A;
	}

	.myCollection_fd1_0_c0_c1_c2_c1 {
		color: #EA3D1A;
		font-weight: 600;
		font-size: 32rpx;
	}

	.myCollection_fd1_0_c0_c1_c2_c0 {
		font-size: 24rpx;
		font-weight: 700;
		color: #EA3D1A;
	}

	.myCollection_fd1_0_c0_c1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd1_0_c0_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 35rpx;
		margin: 16rpx 0rpx 23rpx 0rpx;
	}

	.myCollection_fd1_0_c0_c1_c0 {
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
	}

	.myCollection_fd1_0_c0_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.myCollection_fd1_0_c0_c0 {
		width: 200rpx;
		height: 200rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.myCollection_fd1_0_c0 {
		background: #fff;
		padding: 24rpx 24rpx 24rpx 24rpx;
		margin: 0 24rpx 24rpx;
		border-radius: 16rpx;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c6 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c5 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c4 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.myCollection_price2_fd2_0_c1_c1_c1_c2_c3 {
		font-size: 24rpx;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c3 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		text-decoration: line-through;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx 16rpx;
		text-decoration: line-through;
	}

	.myCollection_price2_fd2_0_c1_c1_c1_c2_c1 {
		font-size: 22rpx;
	}

	.myCollection_price1_fd2_0_c1_c1_c1_c2_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c1 {
		color: #ff5536;
		font-weight: 600;
		font-size: 32rpx;
	}

	.myCollection_fd2_0_c1_c1_c1_c2_c0 {
		font-size: 22rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.myCollection_fd2_0_c1_c1_c1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c1_c1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 35rpx;
		margin: 16rpx 0rpx 23rpx 0rpx;
	}

	.myCollection_fd2_0_c1_c1_c1_c0 {
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
	}

	.myCollection_fd2_0_c1_c1_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.myCollection_fd2_0_c1_c1_c0 {
		width: 200rpx;
		height: 200rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.myCollection_fd2_0_c1_c1 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 16rpx 32rpx 24rpx 24rpx;
		background-size: 100% auto !important;
	}

	.myCollection_fd2_0_c1_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 38rpx 0rpx 32rpx;
	}

	.myCollection_fd2_0_c1 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% auto !important;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c6 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c5 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c4 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.myCollection_price2_fd2_0_c0_c1_c1_c2_c3 {
		font-size: 24rpx;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c3 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		text-decoration: line-through;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 0rpx 0rpx 16rpx;
		text-decoration: line-through;
	}

	.myCollection_price2_fd2_0_c0_c1_c1_c2_c1 {
		font-size: 22rpx;
	}

	.myCollection_price1_fd2_0_c0_c1_c1_c2_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c1 {
		color: #ff5536;
		font-weight: 600;
		font-size: 32rpx;
	}

	.myCollection_fd2_0_c0_c1_c1_c2_c0 {
		font-size: 22rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.myCollection_fd2_0_c0_c1_c1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
	}

	.myCollection_fd2_0_c0_c1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 35rpx;
		margin: 16rpx 0rpx 23rpx 0rpx;
	}

	.myCollection_fd2_0_c0_c1_c1_c0 {
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
	}

	.myCollection_fd2_0_c0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.myCollection_fd2_0_c0_c1_c0 {
		width: 200rpx;
		height: 200rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.myCollection_fd2_0_c0_c1 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 16rpx 32rpx 24rpx 24rpx;
		background-size: 100% auto !important;
	}

	.myCollection_fd2_0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 38rpx 0rpx 32rpx;
	}

	.myCollection_fd2_0_c0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% auto !important;
		overflow: hidden;
	}

	.myCollection_flex_3 {
		background: #fff;
		width: 750rpx;
		height: 100rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	.myCollection_fd3_0_c1 {
		background: #EFEFEF;
		border-radius: 36rpx;
		font-size: 28rpx;
		color: #666;
		width: 160rpx;
		height: 64rpx;
		line-height: 64rpx;
		font-weight: 500;
	}
	.myCollection_fd3_0_c1_x {
		background: #EFEFEF;
		border-radius: 36rpx;
		font-size: 28rpx;
		color: #F35D2A;
		width: 160rpx;
		height: 64rpx;
		line-height: 64rpx;
		font-weight: 500;
		border: 1px solid #F35D2A;
		margin-left: 24rpx;
	}

	.myCollection_fd3_0_c0_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 0rpx 0rpx 14rpx;
	}

	.myCollection_noCheckfd3_0_c0_c0_c1_c0 {
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		width: 36rpx;
		height: 36rpx;
	}

	.myCollection_checkfd3_0_c0_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}

	.myCollection_fd3_0 {
		padding: 0rpx 24rpx 0rpx 32rpx;
	}
</style>